package com.exam.demo.controller;

import com.exam.demo.pojo.Manager;
import com.exam.demo.pojo.Student;
import com.exam.demo.pojo.Teacher;
import com.exam.demo.service.ManagerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("/manager")
//管理管理员的类
public class ManagerController {
    @Autowired
    private ManagerService managerService;

    @RequestMapping("/login")
    //管理员登录，不开放注册接口
    private @ResponseBody Boolean login(@RequestParam("manaNo") String manaNo, @RequestParam("manaPwd") String manaPwd){
        return this.managerService.login(manaNo,manaPwd);
    }

    @RequestMapping("/getinfo")
    private @ResponseBody Manager getInfo(@RequestParam("manaNo") String manaNo){
        return this.managerService.getInfo(manaNo);
    }

    @RequestMapping("/getstulist")
    private @ResponseBody List<Student> getStuList(@RequestParam("manaNo")String manaNo){
        return this.managerService.getStuList(manaNo);
    }

    @RequestMapping("/gettealist")
    private @ResponseBody List<Teacher> getTeaList(@RequestParam("manaNo")String manaNo){
        return this.managerService.getTeaList(manaNo);
    }

    @RequestMapping("/editstuinfo")
    //管理员修改学生个人资料,成功返回1，否则返回0
    private @ResponseBody int changeInfo(@RequestBody Student student){
        return this.managerService.editStuInfo(student);
    }

    @RequestMapping("/editteainfo")
    //管理员修改老师个人资料,成功返回1，否则返回0
    private @ResponseBody int changeInfo(@RequestBody Teacher teacher){
        return this.managerService.editTeaInfo(teacher);
    }

    @RequestMapping("/deletestu")
    //管理员注销学生
    private @ResponseBody int deleteStu(@RequestParam("stuNo") String stuNo){
        return this.managerService.deleteStu(stuNo);
    }

    @RequestMapping("/deletetea")
    //管理员注销老师
    private @ResponseBody int deleteTea(@RequestParam("teaNo") String teaNo){
        return this.managerService.deleteTea(teaNo);
    }
}
